<?php
defined('_XR_EXEC') or die();
/**
 * 逻辑处理类 admin
 */
class Admin_Model extends Model
{ 
	/* 得到当前登录的企业管理员信息 */
	public function getuserinfo(){
		return isset($_SESSION['sys_admin'])?$_SESSION['sys_admin']:false;
	}
	/* 得到当前登录的管理员ID */
	public function getuserid(){ 
		return isset($_SESSION['sys_admin'])?$_SESSION['sys_admin']['id']:0;
	}
	/* 得到当前登录的管理员名称 */
	public function getusername(){ 
		return isset($_SESSION['sys_admin']['username'])?$_SESSION['sys_admin']['username']:'';
	}
	/* 得到姓名 */
	public function getname(){ 
		if($_SESSION['sys_admin']['name'] != ''){
			return $_SESSION['sys_admin']['name'];
		}else{
			return $_SESSION['sys_admin']['username'];
		}
	}
	
	//功能权限
	public function authSys($k='',$getBool=false){
		if($_SESSION['sys_admin']['usertype'] == 1){
			if(in_array($k,$_SESSION['sys_admin']['authinfo']['sys'])){
				return true;
			}else{
				if($getBool){
					return false;
				}else{
					url::msgBox('您暂无权限使用此功能！');
				}
			}
		}
		return true;
	}
	public function get_authgroup_name(){  
			if(!isset($_SESSION['sys_admin']['authgroup_name'])){ 
				$db = factory::getdbo();
				$_SESSION['sys_admin']['authgroup_name'] = $db->loadresult('select name from t_authgroup where id="'.$_SESSION['sys_admin']['authgroup_id'].'" ');
			} 
			return $_SESSION['sys_admin']['authgroup_name'];
	 
	}
  
	
 
	public function get_logincount(){  
			return $_SESSION['sys_admin']['login_count'] ;
	 
	}
	public function get_loginip(){  
			return $_SESSION['sys_admin']['login_ip'] ;
	 
	}
	
	function isSuperAdmin(){
		if($_SESSION['sys_admin']['usertype'] == 1){
			return false;
		}else{
			return true;
		}
	}
	
	
	  
	
  
}

?>